﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using YArchitech.BIM;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HYSpace
{
	public partial class FrmTimeAssignManage : System.Windows.Forms.Form
	{
		public FrmTimeAssignManage(string nodeParent, string nodeText)
		{
			this.InitializeComponent();
			this.tvTimeAssign.HideSelection = false;
			this.tvTimeAssign.DrawMode = TreeViewDrawMode.OwnerDrawText;
			this.tvTimeAssign.DrawNode += this.tvTimeAssign_DrawNode;
			base.Icon = Resource.YArchitechIcon;
			this.btnAdd.Image = Resources.AddNew16;
			this.btnDelete.Image = Resources.delete16;
			this.btnModify.Image = Resources.modify16;
			this.SelecteType = nodeParent;
			this.selectedNodeText = nodeText;
			this.selectedNodeName = nodeText;
			FrmTimeAssignManage.listTimeAssign = this.loadParam.GetAllTimeInfo();
		}

		public FrmTimeAssignManage(string nodeText, IList<TimeAssign> timeAssList)
		{
			this.InitializeComponent();
			this.tvTimeAssign.HideSelection = false;
			this.tvTimeAssign.DrawMode = TreeViewDrawMode.OwnerDrawText;
			this.tvTimeAssign.DrawNode += this.tvTimeAssign_DrawNode;
			base.Icon = Resource.YArchitechIcon;
			this.btnAdd.Image = Resources.AddNew16;
			this.btnDelete.Image = Resources.delete16;
			this.btnModify.Image = Resources.modify16;
			this.selectedNodeText = nodeText;
			this.selectedNodeName = nodeText;
			FrmTimeAssignManage.listTimeAssign = timeAssList;
		}

		private void FrmTimeAssignManage_Load(object sender, EventArgs e)
		{
			foreach (TimeAssign timeAssign in FrmTimeAssignManage.listTimeAssign)
			{
				timeAssign.Operation = "无操作";
			}
			this.BandTreeView(this.tvTimeAssign, FrmTimeAssignManage.listTimeAssign);
			this.BandTimeAssignInfo(this.selectedNodeName, FrmTimeAssignManage.listTimeAssign);
			this.SetTextLeave();
		}

		private void BandTreeView(TreeView treeView, IList<TimeAssign> listTA)
		{
			if (treeView.Nodes.Count > 0)
			{
				treeView.Nodes.Clear();
			}
			TreeNode treeNode = TreeViewTools.CreatTreeViewNode("人员", "人员");
			TreeNode treeNode2 = TreeViewTools.CreatTreeViewNode("新风", "新风");
			TreeNode treeNode3 = TreeViewTools.CreatTreeViewNode("照明", "照明");
			TreeNode treeNode4 = TreeViewTools.CreatTreeViewNode("电子设备", "电子设备");
			TreeNode treeNode5 = TreeViewTools.CreatTreeViewNode("电动设备", "电动设备");
			TreeNode treeNode6 = TreeViewTools.CreatTreeViewNode("电热设备", "电热设备");
			foreach (TimeAssign timeAssign in listTA)
			{
				TreeNode treeNode7 = new TreeNode();
				int startIndex = timeAssign.TsName.IndexOf("_") + 1;
				string tsParent = timeAssign.TsParent;
				if (!(tsParent == "人员"))
				{
					if (!(tsParent == "新风"))
					{
						if (!(tsParent == "照明"))
						{
							if (!(tsParent == "电子设备"))
							{
								if (!(tsParent == "电动设备"))
								{
									if (tsParent == "电热设备")
									{
										treeNode7 = TreeViewTools.CreatTreeViewNode(timeAssign.TsName.Substring(startIndex), timeAssign.TsName);
										treeNode7.Name = timeAssign.Id.ToString();
										treeNode6.Nodes.Add(treeNode7);
										treeNode6.Name = "DR";
									}
								}
								else
								{
									treeNode7 = TreeViewTools.CreatTreeViewNode(timeAssign.TsName.Substring(startIndex), timeAssign.TsName);
									treeNode7.Name = timeAssign.Id.ToString();
									treeNode5.Nodes.Add(treeNode7);
									treeNode5.Name = "DD";
								}
							}
							else
							{
								treeNode7 = TreeViewTools.CreatTreeViewNode(timeAssign.TsName.Substring(startIndex), timeAssign.TsName);
								treeNode7.Name = timeAssign.Id.ToString();
								treeNode4.Nodes.Add(treeNode7);
								treeNode4.Name = "DZ";
							}
						}
						else
						{
							treeNode7 = TreeViewTools.CreatTreeViewNode(timeAssign.TsName.Substring(startIndex), timeAssign.TsName);
							treeNode7.Name = timeAssign.Id.ToString();
							treeNode3.Nodes.Add(treeNode7);
							treeNode3.Name = "ZM";
						}
					}
					else
					{
						treeNode7 = TreeViewTools.CreatTreeViewNode(timeAssign.TsName.Substring(startIndex), timeAssign.TsName);
						treeNode7.Name = timeAssign.Id.ToString();
						treeNode2.Nodes.Add(treeNode7);
						treeNode2.Name = "XF";
					}
				}
				else
				{
					treeNode7 = TreeViewTools.CreatTreeViewNode(timeAssign.TsName.Substring(startIndex), timeAssign.TsName);
					treeNode7.Name = timeAssign.Id.ToString();
					treeNode.Nodes.Add(treeNode7);
					treeNode.Name = "RY";
				}
			}
			treeView.Nodes.Add(treeNode);
			treeView.Nodes.Add(treeNode2);
			treeView.Nodes.Add(treeNode3);
			treeView.Nodes.Add(treeNode5);
			treeView.Nodes.Add(treeNode6);
			treeView.Nodes.Add(treeNode4);
			TreeNode treeNode8 = this.GetTreeNode(this.tvTimeAssign, this.selectedNodeName);
			this.tvTimeAssign.SelectedNode = treeNode8;
			this.tvTimeAssign.Focus();
			this.tvTimeAssign.Select();
		}

		private void SetTextLeave()
		{
			this.ucTimeAssign1.txt00.Leave += this.TextLeave;
			this.ucTimeAssign1.txt01.Leave += this.TextLeave;
			this.ucTimeAssign1.txt02.Leave += this.TextLeave;
			this.ucTimeAssign1.txt03.Leave += this.TextLeave;
			this.ucTimeAssign1.txt04.Leave += this.TextLeave;
			this.ucTimeAssign1.txt05.Leave += this.TextLeave;
			this.ucTimeAssign1.txt06.Leave += this.TextLeave;
			this.ucTimeAssign1.txt07.Leave += this.TextLeave;
			this.ucTimeAssign1.txt08.Leave += this.TextLeave;
			this.ucTimeAssign1.txt09.Leave += this.TextLeave;
			this.ucTimeAssign1.txt10.Leave += this.TextLeave;
			this.ucTimeAssign1.txt11.Leave += this.TextLeave;
			this.ucTimeAssign1.txt12.Leave += this.TextLeave;
			this.ucTimeAssign1.txt13.Leave += this.TextLeave;
			this.ucTimeAssign1.txt14.Leave += this.TextLeave;
			this.ucTimeAssign1.txt15.Leave += this.TextLeave;
			this.ucTimeAssign1.txt16.Leave += this.TextLeave;
			this.ucTimeAssign1.txt17.Leave += this.TextLeave;
			this.ucTimeAssign1.txt18.Leave += this.TextLeave;
			this.ucTimeAssign1.txt19.Leave += this.TextLeave;
			this.ucTimeAssign1.txt20.Leave += this.TextLeave;
			this.ucTimeAssign1.txt21.Leave += this.TextLeave;
			this.ucTimeAssign1.txt22.Leave += this.TextLeave;
			this.ucTimeAssign1.txt23.Leave += this.TextLeave;
		}

		private void TextLeave(object sender, EventArgs e)
		{
			if (base.ActiveControl == this.btnCancle)
			{
				return;
			}
			foreach (TimeAssign timeAssign in FrmTimeAssignManage.listTimeAssign)
			{
				if (timeAssign.Id.ToString() == Convert.ToString(this.ucTimeAssign1.Tag))
				{
					TextBox textBox = (TextBox)sender;
					if (string.IsNullOrEmpty(textBox.Text))
					{
						break;
					}
					if (textBox.Text == ".")
					{
						textBox.Text = "0";
					}
					double num = Convert.ToDouble(textBox.Text);
					if (num < 0.0 || num > 100.0)
					{
						YJKMessageBox.Show("请输入0-100之间的数值");
						textBox.Select();
						break;
					}
					if (timeAssign.Operation == "添加")
					{
						if (!FrmTimeAssignManage.listTimeAssign.Contains(timeAssign))
						{
							FrmTimeAssignManage.listTimeAssign.Add(timeAssign);
						}
					}
					else
					{
						timeAssign.Operation = "修改";
					}
					string name = textBox.Name;
					uint num2 = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(name);
					if (num2 <= 1890726199u)
					{
						if (num2 <= 1739580533u)
						{
							if (num2 <= 1706172390u)
							{
								if (num2 != 1689247676u)
								{
									if (num2 != 1706025295u)
									{
										if (num2 == 1706172390u)
										{
											if (name == "txt18")
											{
												timeAssign.T18 = Convert.ToDouble(textBox.Text) / 100.0;
											}
										}
									}
									else if (name == "txt22")
									{
										timeAssign.T22 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
								else if (name == "txt23")
								{
									timeAssign.T23 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (num2 != 1722802914u)
							{
								if (num2 != 1722950009u)
								{
									if (num2 == 1739580533u)
									{
										if (name == "txt20")
										{
											timeAssign.T20 = Convert.ToDouble(textBox.Text) / 100.0;
										}
									}
								}
								else if (name == "txt19")
								{
									timeAssign.T19 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (name == "txt21")
							{
								timeAssign.T21 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (num2 <= 1840393342u)
						{
							if (num2 != 1806838104u)
							{
								if (num2 != 1823615723u)
								{
									if (num2 == 1840393342u)
									{
										if (name == "txt10")
										{
											timeAssign.T10 = Convert.ToDouble(textBox.Text) / 100.0;
										}
									}
								}
								else if (name == "txt13")
								{
									timeAssign.T13 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (name == "txt12")
							{
								timeAssign.T12 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (num2 != 1857170961u)
						{
							if (num2 != 1873948580u)
							{
								if (num2 == 1890726199u)
								{
									if (name == "txt17")
									{
										timeAssign.T17 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
							}
							else if (name == "txt16")
							{
								timeAssign.T16 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (name == "txt11")
						{
							timeAssign.T11 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (num2 <= 4021630907u)
					{
						if (num2 <= 3937742812u)
						{
							if (num2 != 1907503818u)
							{
								if (num2 != 1924281437u)
								{
									if (num2 == 3937742812u)
									{
										if (name == "txt09")
										{
											timeAssign.T9 = Convert.ToDouble(textBox.Text) / 100.0;
										}
									}
								}
								else if (name == "txt15")
								{
									timeAssign.T15 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (name == "txt14")
							{
								timeAssign.T14 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (num2 != 3954520431u)
						{
							if (num2 != 4004853288u)
							{
								if (num2 == 4021630907u)
								{
									if (name == "txt04")
									{
										timeAssign.T4 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
							}
							else if (name == "txt05")
							{
								timeAssign.T5 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (name == "txt08")
						{
							timeAssign.T8 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (num2 <= 4071963764u)
					{
						if (num2 != 4038408526u)
						{
							if (num2 != 4055186145u)
							{
								if (num2 == 4071963764u)
								{
									if (name == "txt01")
									{
										timeAssign.T1 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
							}
							else if (name == "txt06")
							{
								timeAssign.T6 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (name == "txt07")
						{
							timeAssign.T7 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (num2 != 4088741383u)
					{
						if (num2 != 4105519002u)
						{
							if (num2 == 4122296621u)
							{
								if (name == "txt02")
								{
									timeAssign.T2 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
						}
						else if (name == "txt03")
						{
							timeAssign.T3 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (name == "txt00")
					{
						timeAssign.T0 = Convert.ToDouble(textBox.Text) / 100.0;
					}
				}
			}
		}

		private TreeNode GetTreeNode(TreeView treeView, string nodeName)
		{
			TreeNode result = new TreeNode();
			foreach (object obj in treeView.Nodes)
			{
				TreeNode treeNode = (TreeNode)obj;
				if (treeNode.Name == nodeName)
				{
					result = treeNode;
				}
				foreach (object obj2 in treeNode.Nodes)
				{
					TreeNode treeNode2 = (TreeNode)obj2;
					if (treeNode2.Name == nodeName)
					{
						result = treeNode2;
					}
				}
			}
			return result;
		}

		private void Text_Leave(object sender, EventArgs e)
		{
			foreach (TimeAssign timeAssign in FrmTimeAssignManage.listTimeAssign)
			{
				if (this.ucTimeAssign1.Tag.ToString() == timeAssign.Id.ToString())
				{
					TextBox textBox = (TextBox)sender;
					if (timeAssign.Operation == "添加")
					{
						if (!this.timeAddList.Contains(timeAssign))
						{
							this.timeAddList.Add(timeAssign);
						}
					}
					else
					{
						timeAssign.Operation = "修改";
						if (!this.timeUpdateList.Contains(timeAssign))
						{
							this.timeUpdateList.Add(timeAssign);
						}
					}
					string name = textBox.Name;
					uint num = YArchitech.Revit.PrivateImplementationDetails.ComputeStringHash(name);
					if (num <= 1890726199u)
					{
						if (num <= 1739580533u)
						{
							if (num <= 1706172390u)
							{
								if (num != 1689247676u)
								{
									if (num != 1706025295u)
									{
										if (num == 1706172390u)
										{
											if (name == "txt18")
											{
												timeAssign.T18 = Convert.ToDouble(textBox.Text) / 100.0;
											}
										}
									}
									else if (name == "txt22")
									{
										timeAssign.T22 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
								else if (name == "txt23")
								{
									timeAssign.T23 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (num != 1722802914u)
							{
								if (num != 1722950009u)
								{
									if (num == 1739580533u)
									{
										if (name == "txt20")
										{
											timeAssign.T20 = Convert.ToDouble(textBox.Text) / 100.0;
										}
									}
								}
								else if (name == "txt19")
								{
									timeAssign.T19 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (name == "txt21")
							{
								timeAssign.T21 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (num <= 1840393342u)
						{
							if (num != 1806838104u)
							{
								if (num != 1823615723u)
								{
									if (num == 1840393342u)
									{
										if (name == "txt10")
										{
											timeAssign.T10 = Convert.ToDouble(textBox.Text) / 100.0;
										}
									}
								}
								else if (name == "txt13")
								{
									timeAssign.T13 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (name == "txt12")
							{
								timeAssign.T12 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (num != 1857170961u)
						{
							if (num != 1873948580u)
							{
								if (num == 1890726199u)
								{
									if (name == "txt17")
									{
										timeAssign.T17 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
							}
							else if (name == "txt16")
							{
								timeAssign.T16 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (name == "txt11")
						{
							timeAssign.T11 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (num <= 4021630907u)
					{
						if (num <= 3937742812u)
						{
							if (num != 1907503818u)
							{
								if (num != 1924281437u)
								{
									if (num == 3937742812u)
									{
										if (name == "txt09")
										{
											timeAssign.T9 = Convert.ToDouble(textBox.Text) / 100.0;
										}
									}
								}
								else if (name == "txt15")
								{
									timeAssign.T15 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
							else if (name == "txt14")
							{
								timeAssign.T14 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (num != 3954520431u)
						{
							if (num != 4004853288u)
							{
								if (num == 4021630907u)
								{
									if (name == "txt04")
									{
										timeAssign.T4 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
							}
							else if (name == "txt05")
							{
								timeAssign.T5 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (name == "txt08")
						{
							timeAssign.T8 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (num <= 4071963764u)
					{
						if (num != 4038408526u)
						{
							if (num != 4055186145u)
							{
								if (num == 4071963764u)
								{
									if (name == "txt01")
									{
										timeAssign.T1 = Convert.ToDouble(textBox.Text) / 100.0;
									}
								}
							}
							else if (name == "txt06")
							{
								timeAssign.T6 = Convert.ToDouble(textBox.Text) / 100.0;
							}
						}
						else if (name == "txt07")
						{
							timeAssign.T7 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (num != 4088741383u)
					{
						if (num != 4105519002u)
						{
							if (num == 4122296621u)
							{
								if (name == "txt02")
								{
									timeAssign.T2 = Convert.ToDouble(textBox.Text) / 100.0;
								}
							}
						}
						else if (name == "txt03")
						{
							timeAssign.T3 = Convert.ToDouble(textBox.Text) / 100.0;
						}
					}
					else if (name == "txt00")
					{
						timeAssign.T0 = Convert.ToDouble(textBox.Text) / 100.0;
					}
				}
			}
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void tvTimeAssign_AfterSelect(object sender, TreeViewEventArgs e)
		{
			TreeView treeView = sender as TreeView;
			if (e.Node.Parent == null)
			{
				this.BandTimeAssignInfo(e.Node.Nodes[0].Tag.ToString(), FrmTimeAssignManage.listTimeAssign);
				treeView.Select();
				treeView.SelectedNode = e.Node.Nodes[0];
				foreach (object obj in treeView.Nodes)
				{
					TreeNode treeNode = (TreeNode)obj;
					if (treeNode != e.Node)
					{
						treeNode.Collapse();
					}
				}
				return;
			}
			this.BandTimeAssignInfo(e.Node.Tag.ToString(), FrmTimeAssignManage.listTimeAssign);
		}

		private void BandTimeAssignInfo(string nodeName, IList<TimeAssign> listTA)
		{
			TimeAssign timeAssign = null;
			foreach (TimeAssign timeAssign2 in listTA)
			{
				if (nodeName == timeAssign2.TsName)
				{
					timeAssign = timeAssign2;
					this.ucTimeAssign1.Tag = timeAssign2.Id;
					this.ucTimeAssign1.txt00.Text = StringTools.CutOffEfficacious((timeAssign2.T0 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt00.Tag = this.ucTimeAssign1.txt00.Text;
					this.ucTimeAssign1.txt01.Text = StringTools.CutOffEfficacious((timeAssign2.T1 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt01.Tag = this.ucTimeAssign1.txt01.Text;
					this.ucTimeAssign1.txt02.Text = StringTools.CutOffEfficacious((timeAssign2.T2 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt02.Tag = this.ucTimeAssign1.txt02.Text;
					this.ucTimeAssign1.txt03.Text = StringTools.CutOffEfficacious((timeAssign2.T3 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt03.Tag = this.ucTimeAssign1.txt03.Text;
					this.ucTimeAssign1.txt04.Text = StringTools.CutOffEfficacious((timeAssign2.T4 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt04.Tag = this.ucTimeAssign1.txt04.Text;
					this.ucTimeAssign1.txt05.Text = StringTools.CutOffEfficacious((timeAssign2.T5 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt05.Tag = this.ucTimeAssign1.txt05.Text;
					this.ucTimeAssign1.txt06.Text = StringTools.CutOffEfficacious((timeAssign2.T6 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt06.Tag = this.ucTimeAssign1.txt06.Text;
					this.ucTimeAssign1.txt07.Text = StringTools.CutOffEfficacious((timeAssign2.T7 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt07.Tag = this.ucTimeAssign1.txt07.Text;
					this.ucTimeAssign1.txt08.Text = StringTools.CutOffEfficacious((timeAssign2.T8 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt08.Tag = this.ucTimeAssign1.txt08.Text;
					this.ucTimeAssign1.txt09.Text = StringTools.CutOffEfficacious((timeAssign2.T9 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt09.Tag = this.ucTimeAssign1.txt09.Text;
					this.ucTimeAssign1.txt10.Text = StringTools.CutOffEfficacious((timeAssign2.T10 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt10.Tag = this.ucTimeAssign1.txt10.Text;
					this.ucTimeAssign1.txt11.Text = StringTools.CutOffEfficacious((timeAssign2.T11 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt11.Tag = this.ucTimeAssign1.txt11.Text;
					this.ucTimeAssign1.txt12.Text = StringTools.CutOffEfficacious((timeAssign2.T12 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt12.Tag = this.ucTimeAssign1.txt12.Text;
					this.ucTimeAssign1.txt13.Text = StringTools.CutOffEfficacious((timeAssign2.T13 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt13.Tag = this.ucTimeAssign1.txt13.Text;
					this.ucTimeAssign1.txt14.Text = StringTools.CutOffEfficacious((timeAssign2.T14 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt14.Tag = this.ucTimeAssign1.txt14.Text;
					this.ucTimeAssign1.txt15.Text = StringTools.CutOffEfficacious((timeAssign2.T15 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt15.Tag = this.ucTimeAssign1.txt15.Text;
					this.ucTimeAssign1.txt16.Text = StringTools.CutOffEfficacious((timeAssign2.T16 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt16.Tag = this.ucTimeAssign1.txt16.Text;
					this.ucTimeAssign1.txt17.Text = StringTools.CutOffEfficacious((timeAssign2.T17 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt17.Tag = this.ucTimeAssign1.txt17.Text;
					this.ucTimeAssign1.txt18.Text = StringTools.CutOffEfficacious((timeAssign2.T18 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt18.Tag = this.ucTimeAssign1.txt18.Text;
					this.ucTimeAssign1.txt19.Text = StringTools.CutOffEfficacious((timeAssign2.T19 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt19.Tag = this.ucTimeAssign1.txt19.Text;
					this.ucTimeAssign1.txt20.Text = StringTools.CutOffEfficacious((timeAssign2.T20 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt20.Tag = this.ucTimeAssign1.txt20.Text;
					this.ucTimeAssign1.txt21.Text = StringTools.CutOffEfficacious((timeAssign2.T21 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt21.Tag = this.ucTimeAssign1.txt21.Text;
					this.ucTimeAssign1.txt22.Text = StringTools.CutOffEfficacious((timeAssign2.T22 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt22.Tag = this.ucTimeAssign1.txt22.Text;
					this.ucTimeAssign1.txt23.Text = StringTools.CutOffEfficacious((timeAssign2.T23 * 100.0).ToString(), 2);
					this.ucTimeAssign1.txt23.Tag = this.ucTimeAssign1.txt23.Text;
				}
			}
			TreeNode selectedNode = null;
			foreach (object obj in this.tvTimeAssign.Nodes)
			{
				foreach (object obj2 in ((TreeNode)obj).Nodes)
				{
					TreeNode treeNode = (TreeNode)obj2;
					if (treeNode.Name.ToString() == timeAssign.Id.ToString())
					{
						selectedNode = treeNode;
					}
				}
			}
			this.tvTimeAssign.SelectedNode = selectedNode;
		}

		private void btnAdd_Click(object sender, EventArgs e)
		{
			FrmAddTimeName frmAddTimeName = new FrmAddTimeName(this.tvTimeAssign.SelectedNode.Name);
			if (frmAddTimeName.ShowDialog() == DialogResult.Yes)
			{
				if (FrmTimeAssignManage.listTimeAssign.Contains(frmAddTimeName.tAssign))
				{
					return;
				}
				FrmTimeAssignManage.listTimeAssign.Add(frmAddTimeName.tAssign);
				this.BandTreeView(this.tvTimeAssign, FrmTimeAssignManage.listTimeAssign);
				TreeNode treeNode = this.GetTreeNode(this.tvTimeAssign, frmAddTimeName.tAssign.Id.ToString());
				this.tvTimeAssign.SelectedNode = treeNode;
				this.BandTimeAssignInfo(frmAddTimeName.tAssign.TsName, FrmTimeAssignManage.listTimeAssign);
			}
		}

		public static TimeAssign SetTimeAssign(TimeAssign ta)
		{
			return new TimeAssign
			{
				TsName = ta.TsName,
				TsParent = ta.TsParent,
				Version = ta.Version,
				Id = ta.Id,
				Operation = ta.Operation,
				T0 = ta.T0,
				T1 = ta.T1,
				T10 = ta.T10,
				T11 = ta.T11,
				T12 = ta.T12,
				T13 = ta.T13,
				T14 = ta.T14,
				T15 = ta.T15,
				T16 = ta.T16,
				T17 = ta.T17,
				T18 = ta.T18,
				T19 = ta.T19,
				T2 = ta.T2,
				T20 = ta.T20,
				T21 = ta.T21,
				T22 = ta.T22,
				T23 = ta.T23,
				T3 = ta.T3,
				T4 = ta.T4,
				T5 = ta.T5,
				T6 = ta.T6,
				T7 = ta.T7,
				T8 = ta.T8,
				T9 = ta.T9
			};
		}

		private void IsTextReadOnly(bool isRead)
		{
			this.ucTimeAssign1.txt00.ReadOnly = isRead;
			this.ucTimeAssign1.txt01.ReadOnly = isRead;
			this.ucTimeAssign1.txt02.ReadOnly = isRead;
			this.ucTimeAssign1.txt03.ReadOnly = isRead;
			this.ucTimeAssign1.txt04.ReadOnly = isRead;
			this.ucTimeAssign1.txt05.ReadOnly = isRead;
			this.ucTimeAssign1.txt06.ReadOnly = isRead;
			this.ucTimeAssign1.txt07.ReadOnly = isRead;
			this.ucTimeAssign1.txt08.ReadOnly = isRead;
			this.ucTimeAssign1.txt09.ReadOnly = isRead;
			this.ucTimeAssign1.txt10.ReadOnly = isRead;
			this.ucTimeAssign1.txt11.ReadOnly = isRead;
			this.ucTimeAssign1.txt12.ReadOnly = isRead;
			this.ucTimeAssign1.txt13.ReadOnly = isRead;
			this.ucTimeAssign1.txt14.ReadOnly = isRead;
			this.ucTimeAssign1.txt15.ReadOnly = isRead;
			this.ucTimeAssign1.txt16.ReadOnly = isRead;
			this.ucTimeAssign1.txt17.ReadOnly = isRead;
			this.ucTimeAssign1.txt18.ReadOnly = isRead;
			this.ucTimeAssign1.txt19.ReadOnly = isRead;
			this.ucTimeAssign1.txt20.ReadOnly = isRead;
			this.ucTimeAssign1.txt21.ReadOnly = isRead;
			this.ucTimeAssign1.txt22.ReadOnly = isRead;
			this.ucTimeAssign1.txt23.ReadOnly = isRead;
		}

		private void SetTextBackColor(Color color)
		{
			this.ucTimeAssign1.txt00.BackColor = color;
			this.ucTimeAssign1.txt01.BackColor = color;
			this.ucTimeAssign1.txt02.BackColor = color;
			this.ucTimeAssign1.txt03.BackColor = color;
			this.ucTimeAssign1.txt04.BackColor = color;
			this.ucTimeAssign1.txt05.BackColor = color;
			this.ucTimeAssign1.txt06.BackColor = color;
			this.ucTimeAssign1.txt07.BackColor = color;
			this.ucTimeAssign1.txt08.BackColor = color;
			this.ucTimeAssign1.txt09.BackColor = color;
			this.ucTimeAssign1.txt10.BackColor = color;
			this.ucTimeAssign1.txt11.BackColor = color;
			this.ucTimeAssign1.txt12.BackColor = color;
			this.ucTimeAssign1.txt13.BackColor = color;
			this.ucTimeAssign1.txt14.BackColor = color;
			this.ucTimeAssign1.txt15.BackColor = color;
			this.ucTimeAssign1.txt16.BackColor = color;
			this.ucTimeAssign1.txt17.BackColor = color;
			this.ucTimeAssign1.txt18.BackColor = color;
			this.ucTimeAssign1.txt19.BackColor = color;
			this.ucTimeAssign1.txt20.BackColor = color;
			this.ucTimeAssign1.txt21.BackColor = color;
			this.ucTimeAssign1.txt22.BackColor = color;
			this.ucTimeAssign1.txt23.BackColor = color;
		}

		private void btnModify_Click(object sender, EventArgs e)
		{
			if (this.tvTimeAssign.SelectedNode.Parent == null)
			{
				return;
			}
			FrmModifyTimeAssign frmModifyTimeAssign = new FrmModifyTimeAssign(this.tvTimeAssign.SelectedNode.Text, FrmTimeAssignManage.listTimeAssign);
			if (frmModifyTimeAssign.ShowDialog() == DialogResult.OK)
			{
				this.listRecordInfo.Add(frmModifyTimeAssign.tAssign);
				FrmTimeAssignManage.listTimeAssign = frmModifyTimeAssign.listTA;
				this.selectedNodeText = frmModifyTimeAssign.nodeText;
				this.BandTreeView(this.tvTimeAssign, FrmTimeAssignManage.listTimeAssign);
				this.BandTimeAssignInfo(this.selectedNodeText, FrmTimeAssignManage.listTimeAssign);
			}
		}

		private void tvTimeAssign_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
		{
			if (e.Label != null)
			{
				if (e.Label.Length > 0)
				{
					if (e.Label.IndexOfAny(new char[]
					{
						'@',
						'.',
						',',
						'!'
					}) == -1)
					{
						e.Node.EndEdit(false);
					}
					else
					{
						e.CancelEdit = true;
						e.Node.BeginEdit();
					}
				}
				else
				{
					e.CancelEdit = true;
					e.Node.BeginEdit();
				}
				this.tvTimeAssign.LabelEdit = false;
			}
			foreach (TimeAssign timeAssign in FrmTimeAssignManage.listTimeAssign)
			{
				if (timeAssign.Id.ToString() == e.Node.Name)
				{
					if (string.IsNullOrEmpty(e.Label))
					{
						timeAssign.TsName = timeAssign.TsParent + "_" + e.Node.Text;
					}
					else
					{
						timeAssign.TsName = timeAssign.TsParent + "_" + e.Label;
					}
				}
			}
			foreach (TimeAssign timeAssign2 in FrmTimeAssignManage.listTimeAssign)
			{
				if (e.Node.Name == timeAssign2.Id.ToString())
				{
					if (timeAssign2.Operation == "添加")
					{
						if (!this.timeAddList.Contains(timeAssign2))
						{
							this.timeAddList.Add(timeAssign2);
						}
					}
					else
					{
						timeAssign2.Operation = "修改";
						if (!this.timeUpdateList.Contains(timeAssign2))
						{
							this.timeUpdateList.Add(timeAssign2);
						}
					}
				}
			}
		}

		private void btnDelete_Click(object sender, EventArgs e)
		{
			if (this.tvTimeAssign.SelectedNode.Parent == null)
			{
				return;
			}
			if (this.tvTimeAssign.SelectedNode.Text == "默认")
			{
				YJKMessageBox.Show("默认值不能删除!");
				return;
			}
			string nodeName = this.tvTimeAssign.SelectedNode.Parent.Text + "_默认";
			string text = this.tvTimeAssign.SelectedNode.Text;
			if (YJKMessageBox.Show("确定要删除？", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				TimeAssign timeAssign = new TimeAssign();
				bool flag = false;
				foreach (TimeAssign timeAssign2 in FrmTimeAssignManage.listTimeAssign)
				{
					if (this.tvTimeAssign.SelectedNode.Name == timeAssign2.Id.ToString())
					{
						flag = this.loadParam.DeleteTimeAssign(timeAssign2);
						timeAssign = timeAssign2;
					}
				}
				int count = FrmTimeAssignManage.listTimeAssign.Count;
				FrmTimeAssignManage.listTimeAssign.Remove(timeAssign);
				if (timeAssign.Operation == "添加" && count - FrmTimeAssignManage.listTimeAssign.Count == 1)
				{
					flag = true;
				}
				if (flag)
				{
					YJKMessageBox.Show("删除成功！");
					this.BandTreeView(this.tvTimeAssign, FrmTimeAssignManage.listTimeAssign);
					this.BandTimeAssignInfo(nodeName, FrmTimeAssignManage.listTimeAssign);
					FrmShowInfoGrid.listTAssign = FrmTimeAssignManage.listTimeAssign;
					EditSpaceInfoGrid.listTAssign = FrmTimeAssignManage.listTimeAssign;
				}
			}
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			int num = 0;
			foreach (TimeAssign timeAssign in FrmTimeAssignManage.listTimeAssign)
			{
				string operation = timeAssign.Operation;
				if (!(operation == "添加"))
				{
					if (operation == "修改")
					{
						if (this.loadParam.UpdateTimeAssign(timeAssign))
						{
							num++;
						}
					}
				}
				else if (this.loadParam.AddTimeAssign(timeAssign))
				{
					num++;
				}
			}
			if (num > 0)
			{
				YJKMessageBox.Show("操作成功！");
			}
			foreach (TimeAssign timeAssign2 in FrmTimeAssignManage.listTimeAssign)
			{
				if (this.tvTimeAssign.SelectedNode.Parent.Tag.ToString() == this.SelecteType && this.tvTimeAssign.SelectedNode.Name == timeAssign2.Id.ToString())
				{
					this.selectedNodeText = timeAssign2.TsName;
					break;
				}
			}
			FrmShowInfoGrid.listTAssign = FrmTimeAssignManage.listTimeAssign;
			EditSpaceInfoGrid.listTAssign = FrmTimeAssignManage.listTimeAssign;
			base.DialogResult = DialogResult.OK;
		}

		private void tvTimeAssign_MouseDoubleClick(object sender, MouseEventArgs e)
		{
			if (this.tvTimeAssign.SelectedNode.Parent == null)
			{
				return;
			}
			if (this.tvTimeAssign.SelectedNode.Text == "默认")
			{
				return;
			}
			FrmModifyTimeName frmModifyTimeName = new FrmModifyTimeName(this.tvTimeAssign.SelectedNode.Name);
			if (frmModifyTimeName.ShowDialog() == DialogResult.Yes)
			{
				this.BandTreeView(this.tvTimeAssign, FrmTimeAssignManage.listTimeAssign);
				TreeNode treeNode = this.GetTreeNode(this.tvTimeAssign, frmModifyTimeName.tAssign.Id.ToString());
				this.tvTimeAssign.SelectedNode = treeNode;
				this.BandTimeAssignInfo(frmModifyTimeName.tAssign.TsName, FrmTimeAssignManage.listTimeAssign);
			}
		}

		private void tvTimeAssign_DrawNode(object sender, DrawTreeNodeEventArgs e)
		{
			e.DrawDefault = true;
			if ((e.State & TreeNodeStates.Selected) != (TreeNodeStates)0)
			{
				e.Graphics.FillRectangle(Brushes.DarkBlue, e.Node.Bounds);
				Font font = e.Node.NodeFont;
				if (font == null)
				{
					font = ((TreeView)sender).Font;
				}
				e.Graphics.DrawString(e.Node.Text, font, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
			}
			else
			{
				e.DrawDefault = true;
			}
			if ((e.State & TreeNodeStates.Focused) != (TreeNodeStates)0)
			{
				using (Pen pen = new Pen(Color.Black))
				{
					pen.DashStyle = DashStyle.Dot;
					Rectangle bounds = e.Node.Bounds;
					bounds.Size = new Size(bounds.Width - 1, bounds.Height - 1);
					e.Graphics.DrawRectangle(pen, bounds);
				}
			}
		}

		private void btnModify_Click_1(object sender, EventArgs e)
		{
			if (this.tvTimeAssign.SelectedNode.Parent == null)
			{
				return;
			}
			if (this.tvTimeAssign.SelectedNode.Text == "默认")
			{
				return;
			}
			FrmModifyTimeName frmModifyTimeName = new FrmModifyTimeName(this.tvTimeAssign.SelectedNode.Name);
			if (frmModifyTimeName.ShowDialog() == DialogResult.Yes)
			{
				this.selectedNodeName = frmModifyTimeName.tAssign.TsName;
				this.BandTreeView(this.tvTimeAssign, FrmTimeAssignManage.listTimeAssign);
				TreeNode treeNode = this.GetTreeNode(this.tvTimeAssign, frmModifyTimeName.tAssign.Id.ToString());
				this.tvTimeAssign.SelectedNode = treeNode;
				this.BandTimeAssignInfo(frmModifyTimeName.tAssign.TsName, FrmTimeAssignManage.listTimeAssign);
			}
		}

		public string SelecteType = "";

		public string selectedNodeText = "";

		private string selectedNodeName = "";

		private string[] strList = new string[]
		{
			"人员_默认",
			"新风_默认",
			"照明_默认",
			"电子设备_默认",
			"电热设备_默认",
			"电动设备_默认"
		};

		public static IList<TimeAssign> listTimeAssign = new List<TimeAssign>();

		private List<TimeAssign> timeAddList = new List<TimeAssign>();

		private List<TimeAssign> timeUpdateList = new List<TimeAssign>();

		private List<TimeAssign> listRecordInfo = new List<TimeAssign>();

		private LoadParamOperate loadParam = new LoadParamOperate();
	}
}
